<%@ Page Language="C#" MasterPageFile="~/MasterPages/manager/manager.master" AutoEventWireup="true" CodeFile="AddEditUser.aspx.cs" Inherits="manager_members_AddEditUser" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p><a href="Default.aspx">< Back to User Accounts page</a></p>
    <asp:FormView ID="fvUser" runat="server" DataKeyNames="UserName" DataSourceID="odsMember"
        Width="100%" OnInit="fvUser_Init" OnDataBound="fvUser_DataBound">
        <EditItemTemplate>
            <asp:Button ID="btnEditSave" runat="server" CommandName="Update" Text="Save User Info" />&nbsp;
            <asp:Button ID="btnEditDelete" runat="server" CommandName="Delete" Text="Delete" /><br />
            <br /><asp:Panel ID="panelEditAdminOptions" runat="server" GroupingText="Administrator Options"
                Visible='<%# User.IsInRole("administrator") %>'>
                Customer:
                <asp:DropDownList ID="ddlEditCustomer" runat="server" DataSourceID="odsCustomers" DataTextField="Name" DataValueField="ID">
                </asp:DropDownList><br />
                <br />
                Website:
                <asp:DropDownList ID="ddlEditWebsite" runat="server" DataSourceID="odsEditWebsites" DataTextField="Title" DataValueField="ID">
                </asp:DropDownList><br />
                <asp:ObjectDataSource ID="odsEditWebsites" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="List" TypeName="TanashCMS.Business.TanashWebsite">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlEditCustomer" Name="CustomerID" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
                <br />
                Role:
                <asp:DropDownList ID="ddlEditRole" runat="server" DataSourceID="odsRoles" DataTextField="RoleName"
                    DataValueField="RoleName">
                </asp:DropDownList></asp:Panel>
            <br />
            User Name:<asp:Literal ID="litEditUsername" runat="server" Text='<%# Bind("UserName") %>'></asp:Literal><br />
            First Name:
            <asp:TextBox ID="txtEditFirstName" runat="server" Text='<%# Bind("Firstname") %>'></asp:TextBox><br />
            Surname:
            <asp:TextBox ID="txtEditSurname" runat="server" Text='<%# Bind("Surname") %>'></asp:TextBox><br />
            Email:
            <asp:TextBox ID="txtEditEmail" runat="server" Columns="30" Text='<%# Bind("Email") %>'></asp:TextBox><br />
            <br />
            <strong>
            Change Password<br />
            </strong>Leave these fields blank to leave the current password unchanged.<br />
            New Password:<asp:TextBox ID="txtEditPassword" runat="server" TextMode="Password"></asp:TextBox><br />
            Confirm Password:
            <asp:TextBox ID="txtEditConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
        
</EditItemTemplate>
        <InsertItemTemplate>
<asp:Button id="btnInsertSave" runat="server" CommandName="Insert" Text="Create User" __designer:wfdid="w1"></asp:Button> <asp:Button id="btnInsertCancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:Button><BR /><BR /><asp:Panel id="panelInsertAdminOptions" runat="server" __designer:wfdid="w3" GroupingText="Administrator Options" Visible='<%# User.IsInRole("administrator") %>'>Customer: <asp:DropDownList id="ddlInsertCustomer" runat="server" OnSelectedIndexChanged="ddlInsertCustomer_SelectedIndexChanged" DataValueField="ID" DataTextField="Name" DataSourceID="odsCustomers" AutoPostBack="True" AppendDataBoundItems="true"><asp:ListItem Text="Select..." Selected="True" Value="0"></asp:ListItem>
</asp:DropDownList> <BR /><BR />Website: <asp:DropDownList id="ddlInsertWebsite" runat="server" DataValueField="ID" DataTextField="Title" DataSourceID="odsWebsites"></asp:DropDownList> <BR /><BR />Role: <asp:DropDownList id="ddlInsertRole" runat="server" DataValueField="RoleName" DataTextField="RoleName" DataSourceID="odsRoles">
                </asp:DropDownList></asp:Panel> <BR /><BR />
First Name: <asp:TextBox id="txtInsertFirstname" runat="server" Text='<%# Bind("Firstname") %>'></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="txtInsertFirstname" ErrorMessage="This field is required"></asp:RequiredFieldValidator><BR />Surname: <asp:TextBox id="txtInsertSurname" runat="server" AutoPostBack="True" Text='<%# Bind("Surname") %>' OnTextChanged="txtSurname_TextChanged"></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="txtInsertSurname" ErrorMessage="This field is required"></asp:RequiredFieldValidator><BR />Email: <asp:TextBox id="txtInsertEmail" runat="server" Text='<%# Bind("Email") %>' Columns="30"></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ControlToValidate="txtInsertEmail" ErrorMessage="This field is required"></asp:RequiredFieldValidator><BR /><BR />User Name:<asp:Literal id="litInsertUsername" runat="server" Text='<%# Bind("UserName") %>'></asp:Literal><BR />Password: <asp:TextBox id="txtInsertPassword" runat="server" TextMode="Password"></asp:TextBox><BR />Confirm Password: <asp:TextBox id="txtInsertConfirmPassword" runat="server" TextMode="Password"></asp:TextBox> <asp:CustomValidator id="validatePassword" runat="server" ControlToValidate="txtInsertPassword" ErrorMessage="Passwords must match" EnableClientScript="False"></asp:CustomValidator> 
</InsertItemTemplate>
        <ItemTemplate>
            <h2>
                <asp:Literal ID="litViewName" runat="server" Text='<%# Eval("Firstname") + " " + Eval("Surname") %>'></asp:Literal>&nbsp;</h2>
                <asp:Button ID="btnViewEdit" runat="server" CommandName="Edit" Text="Edit User Info" />&nbsp;
                <asp:Button ID="btnViewDelete" runat="server" CommandName="Delete" Text="Delete" Width="70px" /><br />
            <b><asp:Literal ID="litViewUserName" runat="server" Text='<%# Eval("UserName") %>'></asp:Literal></b><Br />
            <asp:Literal ID="litViewEmail" runat="server" Text='<%# Eval("Email") %>'></asp:Literal><br />
            <br />
            <asp:Panel runat="server" ID="ViewManagerInfo" Visible='<%#User.IsInRole("administrator") %>'>
                Role: <asp:Literal runat="server" ID="litViewRole" Text='<%#Eval("UserName") %>' />
            </asp:Panel>
            <strong>Status:</strong>
            <br />
            <asp:Literal ID="litViewApproved" runat="server" Text='<%# (bool)Eval("IsApproved") ? "Can log in (approved)" : "Cannot log in (not approved)" %>'></asp:Literal><br />
            <asp:Literal ID="litViewLockedOut" runat="server" Text='<%# (bool)Eval("IsLockedOut") ? "Locked out - too many incorrect login attempts" : "Not locked out" %>'></asp:Literal><br />
        
</ItemTemplate>
    </asp:FormView>
    <br />
    <br />
    <asp:ObjectDataSource ID="odsMember" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetMembers" TypeName="MembershipUtilities.MembershipUserAndProfileODS"
        UpdateMethod="Update" OnInserting="odsMember_Inserting">
        <DeleteParameters>
            <asp:Parameter Name="UserName" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="userName" Type="String" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="isLockedOut" Type="Boolean" />
            <asp:Parameter Name="isApproved" Type="Boolean" />
            <asp:Parameter Name="comment" Type="String" />
            <asp:Parameter Name="lastActivityDate" Type="DateTime" />
            <asp:Parameter Name="lastLoginDate" Type="DateTime" />
            <asp:Parameter Name="firstname" Type="String" />
            <asp:Parameter Name="surname" Type="String" />
            <asp:Parameter Name="customerID" Type="Int32" />
            <asp:Parameter Name="websiteID" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:Parameter Name="returnAllApprovedUsers" Type="Boolean" />
            <asp:Parameter Name="returnAllNotApprovedUsers" Type="Boolean" />
            <asp:QueryStringParameter Name="usernameToFind" QueryStringField="username" Type="String" />
            <asp:Parameter Name="sortData" Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="userName" Type="String" />
            <asp:Parameter Name="isApproved" Type="Boolean" />
            <asp:Parameter Name="comment" Type="String" />
            <asp:Parameter Name="lastLockoutDate" Type="DateTime" />
            <asp:Parameter Name="creationDate" Type="DateTime" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="lastActivityDate" Type="DateTime" />
            <asp:Parameter Name="providerName" Type="String" />
            <asp:Parameter Name="isLockedOut" Type="Boolean" />
            <asp:Parameter Name="lastLoginDate" Type="DateTime" />
            <asp:Parameter Name="isOnline" Type="Boolean" />
            <asp:Parameter Name="passwordQuestion" Type="String" />
            <asp:Parameter Name="lastPasswordChangedDate" Type="DateTime" />
            <asp:Parameter Name="password" Type="String" />
            <asp:Parameter Name="passwordAnswer" Type="String" />
            <asp:Parameter Name="firstname" Type="String" />
            <asp:Parameter Name="surname" Type="String" />
            <asp:Parameter Name="customerID" Type="Int32" />
            <asp:Parameter Name="websiteID" Type="Int32" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsRoles" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetRoles" TypeName="MembershipUtilities.RoleDataObjectForMP">
        <DeleteParameters>
            <asp:Parameter Name="roleName" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="roleName" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsCustomers" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="List" TypeName="TanashCMS.Business.TanashCustomer"></asp:ObjectDataSource>
    <asp:ObjectDataSource id="odsWebsites" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="List" TypeName="TanashCMS.Business.TanashWebsite"></asp:ObjectDataSource>
</asp:Content>

